package org.demo.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.demo.entity.HousesDto;
import org.demo.entity.HousesItem;
import org.demo.entity.Housewear;
import org.demo.mapper.HousesItemMapper;
import org.demo.mapper.HousewearMapper;
import org.demo.service.IHousesItemService;
import org.demo.service.IHousewearService;
import org.demo.service.IOrderIdService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class HousesItemServiceImpl extends ServiceImpl<HousesItemMapper, HousesItem> implements IHousesItemService {

    @Autowired
    private IOrderIdService orderIdService;
    @Autowired
    private HousesItemMapper housesItemMapper;

    @Override
    public void add(HousesItem housesItem) {
        String id = orderIdService.getId("HOUSEWEAR");
        housesItem.setId(id);
        save(housesItem);
    }

    @Override
    public HousesDto selectItem(HousesItem housesItem) {
        HousesItem housesItem1 = lambdaQuery().eq(HousesItem::getHousesId,housesItem.getHousesId()).one();

        HousesDto housesDtos = BeanUtil.copyProperties(housesItem1, HousesDto.class);


        return housesDtos;
    }

    @Override
    public void update(HousesItem housesItem) {
        lambdaUpdate().eq(HousesItem::getId,housesItem.getId()).update();
    }

    @Override
    public void delete(String id) {
        housesItemMapper.deleteById(id);
    }
}
